<template>
    <div class="detail-wrapper">
      <el-dialog
        title="修改详情"
        class="tableDialog"
        :visible.sync="detailVisible">
        <div class="detail">
          <table class="detail-table" cellspacing="0" cellpadding="0">
            <tr>
              <td class="table-title">修改时间</td>
              <td class="table-content">{{this.viewForm.createDate}}</td>
              <td class="table-title">修改人</td>
              <td class="table-content"><span v-if="viewForm.createBy !== undefined">{{this.viewForm.createBy.loginName}}</span></td>
              <!--            <td class="table-title">状态：</td>-->
              <!--            <td class="table-content">-->
              <!--              {{$dictUtils.getDictLabel("weightOperateState", this.viewForm.operateState, "")}}-->
              <!--            </td>-->
            </tr>
            <tr>
              <td class="table-title">修改前</td>
              <td class="table-content">
                <p v-if="this.showOldTransCode">派车单号：{{this.showOldTransCode}}</p>
                <p v-if="this.showOldPlanCode">发运计划：{{this.showOldPlanCode}}</p>
                <p v-if="this.showOldTruckNumber">车牌号：{{this.showOldTruckNumber}}</p>
                <p v-if="this.showOldDriverName">司机姓名：{{this.showOldDriverName}}</p>
                <p v-if="this.showOldDeductWeight">暗扣：{{this.showOldDeductWeight}}</p>
                <p v-if="this.showOldDeductWeightWater">扣水：{{this.showOldDeductWeightWater}}</p>
                <p v-if="this.showOldDeductWeightImpurity">扣杂：{{this.showOldDeductWeightImpurity}}</p>
                <p v-if="this.showOldOverloadAdjustWeight">超载调整：{{this.showOldOverloadAdjustWeight}}</p>
                <p v-if="this.showOldOriginalWeight">原发数：{{this.showOldOriginalWeight}}</p>
                <p v-if="this.showOldAllowLossWeight">合理路耗：{{this.showOldAllowLossWeight}}</p>
              </td>
              <td class="table-title">修改后</td>
              <td class="table-content">
                <p v-if="this.showNewTransCode">派车单号：{{this.showNewTransCode}}</p>
                <p v-if="this.showNewPlanCode">发运计划：{{this.showNewPlanCode}}</p>
                <p v-if="this.showNewTruckNumber">车牌号：{{this.showNewTruckNumber}}</p>
                <p v-if="this.showNewDriverName">司机姓名：{{this.showNewDriverName}}</p>
                <p v-if="this.showNewDeductWeight">暗扣：{{this.showNewDeductWeight}}</p>
                <p v-if="this.showNewDeductWeightWater">扣水：{{this.showNewDeductWeightWater}}</p>
                <p v-if="this.showNewDeductWeightImpurity">扣杂：{{this.showNewDeductWeightImpurity}}</p>
                <p v-if="this.showNewOverloadAdjustWeight">超载调整：{{this.showNewOverloadAdjustWeight}}</p>
                <p v-if="this.showNewOriginalWeight">原发数：{{this.showNewOriginalWeight}}</p>
                <p v-if="this.showNewAllowLossWeight">合理路耗：{{this.showNewAllowLossWeight}}</p>
              </td>
            </tr>
          </table>
        </div>
      </el-dialog>
    </div>
</template>

<script>
    import {getById} from '@/api/warehouse/change/WarehouseChange.js';
    export default {
      name: 'details',
      data () {
        return {
          detailVisible: false,
          truckNumber: '',
          viewForm: {},
          showOldTransCode: '',
          showOldPlanCode: '',
          showOldTruckNumber: '',
          showOldDriverName: '',
          showOldDeductWeight: '',
          showOldDeductWeightWater: '',
          showOldDeductWeightImpurity: '',
          showOldOverloadAdjustWeight: '',
          showOldOriginalWeight: '',
          showOldAllowLossWeight: '',
          showNewTransCode: '',
          showNewPlanCode: '',
          showNewTruckNumber: '',
          showNewDriverName: '',
          showNewDeductWeight: '',
          showNewDeductWeightWater: '',
          showNewDeductWeightImpurity: '',
          showNewOverloadAdjustWeight: '',
          showNewOriginalWeight: '',
          showNewAllowLossWeight: '',
          inputForm: {
            id: '',
            businessProductId: '',
            procInsId: '',
            businessId: '',
            productId: '',
            payMode: 0,
            selectVos: [],
            companyName: '',
            price: '',
            productName: '',
            contractCode: '',
            effectTime: '',
            newPrice: ''
          },
          operateOld: {},
          operateNew: {},
        }
      },
      methods: {
        init (method, row) {
          if (method === 'detail') {
            this.detailVisible = true
            this.showOldTransCode = ''
            this.showOldPlanCode = ''
            this.showOldTruckNumber = ''
            this.showOldDriverName = ''
            this.showOldDeductWeight = ''
            this.showOldDeductWeightWater = ''
            this.showOldDeductWeightImpurity = ''
            this.showOldOverloadAdjustWeight = ''
            this.showOldOriginalWeight = ''
            this.showOldAllowLossWeight = ''
            this.showNewTransCode = ''
            this.showNewPlanCode = ''
            this.showNewTruckNumber = ''
            this.showNewDriverName = ''
            this.showNewDeductWeight = ''
            this.showNewDeductWeightWater = ''
            this.showNewDeductWeightImpurity = ''
            this.showNewOverloadAdjustWeight = ''
            this.showNewOriginalWeight = ''
            this.showNewAllowLossWeight = ''
            this.$http({
              url: `/weight/exceptionQuery/queryById?id=${row.id}`,
              method: 'get'
            }).then(({data}) => {
              this.viewForm = data.result
              this.inputForm = this.recover(this.inputForm, data.result)
              this.operateOld = JSON.parse(this.viewForm.operateOld)
              if (this.operateOld.deductWeight) {
                this.showOldDeductWeight = this.operateOld.deductWeight
              }
              if (this.operateOld.deductWeightWater) {
                this.showOldDeductWeightWater = this.operateOld.deductWeightWater
              }
              if (this.operateOld.deductWeightImpurity) {
                this.showOldDeductWeightImpurity = this.operateOld.deductWeightImpurity
              }
              if (this.operateOld.overloadAdjustWeight) {
                this.showOldOverloadAdjustWeight = this.operateOld.overloadAdjustWeight
              }
              if (this.operateOld.originalWeight) {
                this.showOldOriginalWeight = this.operateOld.originalWeight
              }
              if (this.operateOld.allowLossWeight) {
                this.showOldAllowLossWeight = this.operateOld.allowLossWeight
              }
              if (this.operateOld.planCode) {
                this.showOldPlanCode = this.operateOld.planCode
              }
              if (this.operateOld.transCode) {
                this.showOldTransCode = this.operateOld.transCode
              }
              if (this.operateOld.driverName) {
                this.showOldDriverName = this.operateOld.driverName
              }
              if (this.operateOld.truckNumber) {
                this.showOldTruckNumber = this.operateOld.truckNumber
              }
              this.operateNew = JSON.parse(this.viewForm.operateNew)
              if (this.operateNew.deductWeight) {
                this.showNewDeductWeight = this.operateNew.deductWeight
              }
              if (this.operateNew.deductWeightWater) {
                this.showNewDeductWeightWater = this.operateNew.deductWeightWater
              }
              if (this.operateNew.deductWeightImpurity) {
                this.showNewDeductWeightImpurity = this.operateNew.deductWeightImpurity
              }
              if (this.operateNew.overloadAdjustWeight) {
                this.showNewOverloadAdjustWeight = this.operateNew.overloadAdjustWeight
              }
              if (this.operateNew.originalWeight) {
                this.showNewOriginalWeight = this.operateNew.originalWeight
              }
              if (this.operateNew.allowLossWeight) {
                this.showNewAllowLossWeight = this.operateNew.allowLossWeight
              }
              if (this.operateNew.planCode) {
                this.showNewPlanCode = this.operateNew.planCode
              }
              if (this.operateNew.transCode) {
                this.showNewTransCode = this.operateNew.transCode
              }
              if (this.operateNew.driverName) {
                this.showNewDriverName = this.operateNew.driverName
              }
              if (this.operateNew.truckNumber) {
                this.showNewTruckNumber = this.operateNew.truckNumber
              }
              this.loading = false
            })
          }
        }
      }
    }
</script>

<style lang="scss" scoped>
  .detail-wrapper{
    ::v-deep.el-dialog{
      .el-dialog__body{
        .title{
          margin-bottom: 10px;
        }
        .detail-table{
          border: 1px solid #DDDDDD;
          border-bottom: none;
          td{
            padding: 12px 10px;
            border-right: 1px solid #DDDDDD;
            border-bottom: 1px solid #DDDDDD;
          }
          .table-title{
            width: 125px;
            font-size: 14px;
            font-family: Microsoft YaHei;
            font-weight: 400;
            color: #999999;
          }
          .table-content{
            width: 260px;
            font-size: 14px;
            font-family: Microsoft YaHei;
            font-weight: 400;
            color: #333333;

            span:first-child{
              margin-right: 20px;
            }
          }
        }
      }
    }

  }
</style>
